#pragma once

#include "HashTable.h"

namespace bit
{
	template <class K, class Hash = HashFunc<K>>
	class unordered_set
	{
		struct SetOfT
		{
			const K& operator()(const K& key)
			{
				return key;
			}
		};

	public:
		typedef typename HashBucket<K, const K, SetOfT, Hash>::Iterator iterator;
		typedef typename HashBucket<K, const K, SetOfT, Hash>::ConstIterator const_iterator;

		iterator begin()
		{
			return ht.Begin();
		}

		iterator end()
		{
			return ht.End();
		}

		const_iterator begin()const
		{
			return ht.Begin();
		}

		const_iterator end()const
		{
			return ht.End();
		}

		pair<iterator, bool> insert(const K& key)
		{
			return ht.Insert(key);
		}

	private:
		bit::HashBucket<K,const K, SetOfT, Hash> ht;

	};

	void Print(const unordered_set<int>& s)
	{
		unordered_set<int>::const_iterator it = s.begin();
		while (it != s.end())
		{
			// *it += 1;
			cout << *it << " ";
			++it;
		}
		cout << endl;
	}

	void Test_set()
	{
		//int a[] = { 8, 3, 1, 10, 6, 4, 7, 14, 13 };
		int a[] = { 16,3,7,11,9,26,18,14,15 };
		unordered_set<int> s;

		for (auto e : a)
			s.insert(e);

		for (auto e : s)
			cout << e << " ";

		cout << endl;

		Print(s);
	}
}